package com.example.activities;

import BDD.DataBaseHelper;
import BDD.Queries;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Environment;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import java.io.File;
import java.util.ArrayList;

import android.widget.TextView;
import com.example.R;


public class ViewPhoto extends Activity {

    File myDirectory = new File(Environment.getExternalStorageDirectory() + "/AppImages/");
    File photo;
    ArrayList<String> listOfPersons = new ArrayList<String>();
    TextView placeView;
    TextView contactView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.viewphoto);

        int position = this.getIntent().getExtras().getInt("position");
        ImageView imageView = (ImageView) findViewById(R.id.imageView);
        photo = myDirectory.listFiles()[position];
        placeView = (TextView) findViewById(R.id.placeView);
        contactView = (TextView) findViewById(R.id.contactView);
        Cursor c = Queries.getPicture(photo.getAbsolutePath());
        if (c.getCount() != 0) {
            c.moveToFirst();
            placeView.setText(c.getString(1));
            contactView.setText(c.getString(2));
            c.close();
        }
        imageView.setImageDrawable(Drawable.createFromPath(photo.getAbsolutePath()));
    }

    public void back(View view) {
        Intent intent = new Intent(ViewPhoto.this, MainGallery.class);
        startActivity(intent);
    }
    
    public void peopleAdvertisementButtonClick(View view) {
        SmsManager smsManager = SmsManager.getDefault();
        try {
            contactView = (TextView) findViewById(R.id.contactView);
            String listOfNames = (String)contactView.getText();
            String message = "T es trop sympa";

            //smsManager.sendTextMessage(numero, null, message, null, null);
            //Toast.makeText(EnvoiSMS.this, "SMS envoyé", Toast.LENGTH_LONG).show();
        } catch (Exception e) {

        }
    }
}


